Class Libraries
Have a library of classes available May just re-use existing classes to make the program. Can make objects of a class type
Nouns: Used to help identify objects Verbs: Used to identify functionality
Currently considering ER-diagrams
- In ER diagrams we care about the data, how to group it and how it is related to other data
- In OO class diagrams we care about what is done and what is doing it.
- If have a class library we will usually start by looking at what it can do and fit our plans around it - work out how to use it for our needs
- Java Swing provides a lot of 'base classes' that can create objects from, or inherit own classes to alter behaviour.
Java swing user interface classes
- Top Level Window: JFrame
- Controls/Components
- JButton
- JLabel
- JTextField
- JListbox
- Other useful classes include font and layout managers
Object references are not objects. The store references to objects. Similar to a pointer Objects get created using new. Static variables are NOT in objects - they are shared Static methods are NOT associated with a specific object
Aggregation
If the new class must have the original class. Should use aggregation if part of the interface is not used or has to be changed to avoid an illogical situation.
Create new functionality by taking other classes and combining them into a new class. Attach an common interface to this new class for interoperability with other code
Inheritance
If the new class is more or less as the original class. The new class is now a subclass of the original class. Only use if we need almost all of the functionality without major changes.
Extend the functionality of a class by creating a subclass. Override superclass members in the subclasses to provide new functionality. Make methods abstract/virtual to force subclasses to "fill-in-the-blanks" when the superclass wants a particular interface but is agnostic about its implementation.